package com.example.apple.lwb_json;

import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.example.apple.lwb_json.DATA.Data;

import org.json.JSONObject;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Request get = new Request();
        get.doGet("http://v.juhe.cn/weather/index","?cityname="+"株洲"+"&key=c28170eb40b881e6a663ed2b73e0de2a",new Handler(){
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                JSONObject jsonObject =(JSONObject) msg.obj;
                JSONModel jsonModel = new JSONModel();
                Map<String,String> map23 =new HashMap();
                map23.put("futureSevenDays","OneDayWeatherData");
                jsonModel.setEntityClasss(map23);
                Log.e("JSONModel-->", String.valueOf(jsonModel.initWithDictionary(jsonObject,"com.example.apple.lwb_json.DATA.","Data")));
                Data data1 =(Data) jsonModel.initWithDictionary(jsonObject,"com.example.apple.lwb_json.DATA.","Data");
                Log.e("J--->",data1.getResult().getSk().getTemp());
            }
        });
    }
}
